package org.example;

import java.time.LocalDateTime;

public class Logger {
    private final Class<?> clazz;

    private Logger(Class<?> clazz) {
        this.clazz = clazz;
    }

    public static Logger getLogger(Class<?> clazz) {
        return new Logger(clazz);
    }

    public void info(String info) {
        System.out.println(formatMsg(info));
    }

    public void error(String error, Exception e) {
        System.out.println(formatMsg(error));
        e.printStackTrace();
    }

    private static final String format = "[%s][%s][%s]";
    private String formatMsg(String msg) {
        return String.format(format, LocalDateTime.now().toString(), clazz.getName(), msg);
    }
}
